package com.hdsx.restful.glzt.roadline.cfld.rest;

import java.util.List;

import javax.annotation.Resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.springframework.stereotype.Service;

import com.hdsx.restful.glzt.roadline.cfld.bean.Cfld;
import com.hdsx.restful.glzt.roadline.cfld.service.CfldService;
import com.hdsx.restful.util.EasyUI;

@Path("/cfld")
@Service
public class CfldRestServer {
	@Resource(name="cfldServiceImpl")
	private CfldService cfldService;

	/**
	 * http://192.168.0.103:8080/restful/rest/cfld/list?lxdm=G310&page=0&rows=10
	 * @param lxdm
	 * @param page
	 * @param rows
	 * @return
	 */
	@GET
	@Path("/list")
	@Produces(MediaType.APPLICATION_JSON)
	public EasyUI<Cfld> queryList(@QueryParam("lxdm") String lxdm,@QueryParam("page") int page,@QueryParam("rows") int rows) {
		EasyUI<Cfld> uiPage = new EasyUI<Cfld>(page, rows);
		int count =cfldService.queryCountByParameter(lxdm);
		List<Cfld> servicefws= cfldService.queryByParameter(lxdm,uiPage.getBegin(),uiPage.getEnd());
		uiPage.setTotal(count);
		uiPage.setRows(servicefws);
		return uiPage;
	}
	
	@GET
	@Path("/queryCfldString")
	@Produces(MediaType.APPLICATION_JSON)
	public String queryCfldString(@QueryParam("id") String id)
	{
		return cfldService.queryCfldString(id);
	}
	
}
